package com.softstao.guoyu.mvp.presenter.agent;

import com.softstao.guoyu.model.agent.AgentList;
import com.softstao.guoyu.model.agent.MonthCondition;
import com.softstao.guoyu.model.agent.MonthDetail;
import com.softstao.guoyu.model.agent.MonthOrderList;
import com.softstao.guoyu.model.agent.MonthProList;
import com.softstao.guoyu.model.agent.ParentInfoIndex;
import com.softstao.guoyu.model.agent.ShareInvite;
import com.softstao.guoyu.model.agent.SubApplyList;
import com.softstao.guoyu.model.agent.SubInfo;
import com.softstao.guoyu.model.agent.TeamCount;
import com.softstao.guoyu.model.sale.OrderDetail;
import com.softstao.guoyu.mvp.interactor.agent.AgentInteractor;
import com.softstao.guoyu.mvp.presenter.BasePresenter;
import com.softstao.guoyu.mvp.viewer.BaseViewer;
import com.softstao.guoyu.mvp.viewer.agent.AgentListViewer;
import com.softstao.guoyu.mvp.viewer.agent.AuditViewer;
import com.softstao.guoyu.mvp.viewer.agent.GetInviteViewer;
import com.softstao.guoyu.mvp.viewer.agent.MonthDetailViewer;
import com.softstao.guoyu.mvp.viewer.agent.MonthOrderDetailViewer;
import com.softstao.guoyu.mvp.viewer.agent.MonthOrderViewer;
import com.softstao.guoyu.mvp.viewer.agent.MonthProViewer;
import com.softstao.guoyu.mvp.viewer.agent.ParentInfoViewer;
import com.softstao.guoyu.mvp.viewer.agent.SubApplyViewer;
import com.softstao.guoyu.mvp.viewer.agent.SubInfoViewer;
import com.softstao.guoyu.mvp.viewer.agent.TeamCountViewer;

/**
 * Created by vaikus on 2017/6/27.
 */

public class AgentPresenter extends BasePresenter<BaseViewer,AgentInteractor> {
    public void getTeamCount(int agentId){
        interactor.getTeamCount(agentId,o -> ((TeamCountViewer)viewer).getResult((TeamCount) o));
    }

    public void getParentInfo(int agentId,int parentId){
        interactor.getParentInfo(agentId,parentId,o -> ((ParentInfoViewer)viewer).getParentInfo((ParentInfoIndex) o));
    }

    public void getAgentList(String type,int agentId){
        switch (type){
            case "direct":
                interactor.getDirectSub(agentId,o -> ((AgentListViewer)viewer).getList((AgentList) o));
                break;
            case "to":
                interactor.recommendToMe(agentId,o -> ((AgentListViewer)viewer).getList((AgentList) o));
                break;
            case "from":
                interactor.recommendFromMe(agentId,o -> ((AgentListViewer)viewer).getList((AgentList) o));
                break;
            case "no_order":
                interactor.noOrderMonth(agentId,o -> ((AgentListViewer)viewer).getList((AgentList) o));
                break;
        }
    }

    public void getSubInfo(int agentId, int subAgentId){
        interactor.getSubInfo(agentId,subAgentId,o -> ((SubInfoViewer)viewer).getResult((SubInfo) o));
    }

    public void getMonthDetail(int agentId, String subAgentId, String month){
        interactor.getMonthDetail(agentId,subAgentId,month,o -> ((MonthDetailViewer)viewer).getMonthDetail((MonthDetail) o));
    }

    public void getMonthOrder(int page, MonthCondition condition){
        interactor.getMonthOrder(page,condition,o -> ((MonthOrderViewer)viewer).getMonthOrderList((MonthOrderList) o));
    }

    public void getMonthOrderDetail(int agentId, String orderCode){
        interactor.getMonthOrderDetail(agentId,orderCode,o -> ((MonthOrderDetailViewer)viewer).getMonthOrderDetail((OrderDetail) o));
    }

    public void getMonthPro(int page,MonthCondition condition){
        interactor.getMonthPro(page,condition,o -> ((MonthProViewer)viewer).getMonthProList((MonthProList) o));
    }

    public void getAllSub(int agentId){
        interactor.getAllSub(agentId,o -> ((AgentListViewer)viewer).getList((AgentList) o));
    }

    public void getInvite(int agentId){
        interactor.getInvite(agentId,o -> ((GetInviteViewer)viewer).getResult((ShareInvite) o));
    }

    public void getSubApply(int page,int agentId,int state){
        interactor.getSubApply(page,agentId,state,o -> ((SubApplyViewer)viewer).getList((SubApplyList) o));
    }

    public void passAudit(int agentId,int processId,String img,String reason){
        interactor.passAudit(agentId,processId,img,reason,o -> ((AuditViewer)viewer).passResult(o));
    }

    public void rejectAudit(int agentId,int processId,String reason){
        interactor.rejectAudit(agentId,processId,reason,o -> ((AuditViewer)viewer).rejectResult(o));
    }
}
